import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/lifeCircle/data/repository/life_repository.dart';
import 'package:casdon/modules/lifeCircle/providers/life_provider.dart';
import 'package:casdon/modules/me/data/api/user_center_api.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class LifeBloggerInfoUsecase {
  final LifeRepository _repository;

  const LifeBloggerInfoUsecase(this._repository);

  Future<ResponseUserCenterApi?> execute({required String userId}) async {
    try {
      var ret = await _repository.getBloggerLifeInfo(userId: userId);
      return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("LifeBloggerInfoUsecase 失败", e.toString(), StackTrace.current);
      throw Exception("LifeBloggerInfoUsecase 失败");
    }
  }
}

final lifeBloggerInfoUsecaseProvider = Provider(
  (ref) => LifeBloggerInfoUsecase(ref.read(lifeRepository)),
);
